#include <string.h>
#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <clocale>
#include <list>
#include <fstream>
#include <vector>
#include <clocale>
#include "hr_time.h"
#include <Windows.h>
#include "ip_addresser.h"
#include "data.h"
#include <queue>
#include <map>
# pragma once

using namespace std;
namespace u31
{
	
	int RFac(int n)
	{
		if (n == 0)
		{
			return 1;
		}
		else
		{
			return n*RFac(n - 1);
		}
	}

	

	int IFac(int n)
	{
		int sum = 1;
		for (int i = 1; i < n; i++){
			sum = sum*(i+1);

		}
		
		return sum;
	}


	double aSum(int n, int x){
		double sum = 0;
		for (int i = 0; i <= n; i++){
			sum = sum +(x^i / RFac(i));
			
		}
		return sum;
	
	}

	double bSum(int n, int x){
		double sum = 0;
		for (int i = 0; i <= n; i++){
			sum = sum + (x^i / IFac(i));

		}
		return sum;

	}

	
	void mainone(){

		SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
		SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);

		CStopWatch w;

		cout << "UPPG 3.1 a" << endl;

		cout << RFac(4) << "=" << IFac(4) << endl;


		w.startTimer();
		cout << aSum(2 , 4) << endl;
		w.stopTimer();
		cout << "Time =" << w.getElapsedTime() * 1000 << "ms" << endl;


		w.startTimer();
		cout << bSum(2, 4) << endl;
		w.stopTimer();
		cout << "Time =" << w.getElapsedTime() * 1000 << "ms" << endl;

		


		system("pause");
	}

}




namespace u32{

	void maintwo(){

		cout << "u 32" << endl;

		ip_addresser a;
		
		a.ReadFromFile("C:/Users/Jonas/Desktop/ip_two.txt");

		cout<<a.TellSize()<<endl;

		//cout << a.printFirst()<<endl;
		
		std::priority_queue<data> pq;
		//std::map<int,int>::iterator it;

		for (std::map<int, int>::iterator it = a.begin(); it != a.end(); ++it)
			std::cout << it->first << " => " << it->second << '\n';


		for (it = a.begin(); it <= a.end(); ++it)
			std::cout << it->first << " => " << it->second << '\n';

		pq.push(data(it->first, it->second));

		system("pause");
	}





}




int main(){
	u31::mainone();
	u32::maintwo();



}